<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>叩丁狼骡窝窝后台管理系统</title>
    <#include "../common/header.ftl" >

    <style>
        .modal-body img {
            width: 100%;
        }
    </style>
    <script>
        $(function () {
            //查看文章按钮
            $(".lookBtn").click(function () {
                var id = $(this).data("id");
                //发送ajax请求查询游记内容
                $.get('/travel/getContentById', {id: id}, function (data) {
                    $(".modal-body").html(data.data.content);
                })

                $("#contentModal").modal('show');
            })


            $('.changeStateBtn').click(function () {
                var state = $(this).data('state');
                var id = $(this).data('id');
                $.get("/travel/updateState", {id: id, state: state}, function (data) {
                    if (data.success) {
                        window.location.reload();
                    }
                })
            })
        })
    </script>

</head>
<body>

<div class="container " style="margin-top: 20px">
<#--查看文章内容模态框-->
    <div class="modal fade" id="contentModal" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">文章内容</h4>
                </div>
                <div class="modal-body">
                    xxxxxxxxx
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#assign currentMenu="travel"/>
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记页面</h1>
                </div>
            </div>

            <div class="row">

                <div>
                    <form class="form-inline" id="searchForm" action="/travel/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <select id="auditState" class="form-control" autocomplete="off" name="state">

                                <option value="-1">全&nbsp;&nbsp;部</option>
                                <option value="1">待审核</option>
                                <option value="2">已发布</option>
                                <option value="3">已拒绝</option>
                            </select>
                            <script>
                                $("#auditState").val(${(qo.state)!});
                            </script>
                            <button id="query" type="submit" class="btn btn-success"><i class="icon-search"></i> 查询
                            </button>
                        </div>

                    </form>
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>标题</th>
                            <th>封面</th>
                            <th>地点</th>
                            <th>作者</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pageInfo.list as t>
                        <tr>
                            <td>${t_index+1}</td>
                            <td>${t.title}</td>
                            <td><img src="${t.coverUrl}" width="70"></td>
                            <td>${t.dest.name}</td>
                            <td>${t.author.nickname}</td>
                            <td>${t.stateDisplay}</td>
                            <td>
                            <#if  t.state == 2>
                                <a class="btn btn-danger btn-xs changeStateBtn" href="javascript:;" data-state='1'
                                   data-id="${t.id}">
                                    <span class="glyphicon glyphicon-minus-sign"></span> 下架
                                </a>

                            <#elseif t.state == 1>
                            <a class="btn btn-default btn-xs changeStateBtn" href="JavaScript:;" data-state="2"
                               data-id="${t.id}">
                                <span class="glyphicon glyphicon-tag"></span> 发布
                            </a>
                            </#if>
                        <#if t.state==1>
                            <a class="btn btn-danger btn-xs changeStateBtn" href="JavaScript:;" data-state="3"
                               data-id="${t.id}">
                                <span class="glyphicon glyphicon-trash"></span> 拒绝
                            </a>
                        </#if>
                            </td>
                            <td>
                                <a href="javascript:void(0);" class="lookBtn btn btn-info btn-xs btn-input"
                                   data-id="${t.id}">查看文章</a>
                            </td>
                        </tr>
                        </#list>
                        </tbody>
                    </table>
                    <#include "../common/page.ftl" />
                </div>
            </div>

        </div>
    </div>
</div>
</body>
</html>